-
-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
!!! BUGFIX: Consider entry node when filtering in reference editor #5195
!!! BUGFIX: Consider entry node when filtering in reference editor #5195
Conversation
…reference editor)
@@ -76,8 +76,9 @@ Feature: Find and count nodes using the findChildNodes and countChildNodes queri | |||
| a1 | Neos.ContentRepository.Testing:Page | a | {"text": "a1"} | {} | | |||
| a2 | Neos.ContentRepository.Testing:Page | a | {"text": "a2"} | {} | | |||
| a2a | Neos.ContentRepository.Testing:SpecialPage | a2 | {"text": "a2a"} | {} | | |||
| a2a1 | Neos.ContentRepository.Testing:Page | a2a | {"text": "a2a1", "stringProperty": "the brown fox", "booleanProperty": true, "integerProperty": 33, "floatProperty": 12.345, "dateProperty": {"__type": "DateTimeImmutable", "value": "1980-12-13"}} | {} | | |||
| a2a1 | Neos.ContentRepository.Testing:Page | a2a | {"text": "a2a1", "stringProperty": "the brown fox likes Äpfel", "booleanProperty": true, "integerProperty": 33, "floatProperty": 12.345, "dateProperty": {"__type": "DateTimeImmutable", "value": "1980-12-13"}} | {} | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the veto, but I have a couple of concerns. The main one being: This adds/duplicates logic from the core to the controller/runtime.
E.g. replicating search term matching to PHP code might behave slightly different from the other implementations and that would be a huge can of worms..
I think, extending the FindDescendantNodesFilter
by some includeEntryNode
as discussed via Slack would be a more stable and clean solution – even though it has that slight naming inaccuracy (which we could solve if we really wanted to)
@@ -12,7 +12,7 @@ | |||
|
|||
declare(strict_types=1); | |||
|
|||
namespace Neos\ContentRepository\Core\Projection\ContentGraph; | |||
namespace Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, we had it in the main ContentGraph folder by intention because it is likely to be reused for other parts.
Can be discussed, but IMO we should not sneak in such changes in unrelated PRs as it makes the review needlessly harder and could confuse debugging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I would also let it stay where it was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the rest of the changes I came to understand why you moved it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would almost argue the SearchTermMatcher doesn't belong in Projection/ContentGraph/Filters and that strengthens the argument the SearchTerm should be generic as well. Yes the SearchTermMatcher applies to contentgraph projection nodes, BUT I tihnk it's clear that everything else in filters is used in conjunction with a ContentGraph or Subgraph query (query in the loosest term not necessarily DB query), while the SearchTermMatcher applies to a set of nodes that have already been assembled. I think that is its own kind of operation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i moved it to align it to the PropertyValueCriteriaMatcher
it resides as well in the PropertyValue
namespace and it was only logical to me that the same should apply for SearchTerm
things. Id be fine with that non-ideal namespace for now as the SearchTermMatcher
is marked as @internal
for now and we can later decide on a better location for this and the PropertyValueCriteriaMatcher
. Or is there a better suggestion out there? Probably with the introduction of the inmemory content graph well have a better namespace at hand.
...ntentRepository.Core/Classes/Projection/ContentGraph/Filter/SearchTerm/SearchTermMatcher.php
Show resolved
Hide resolved
} | ||
$nodes = $nodes->merge( | ||
$subgraph->findDescendantNodes($entryNode->aggregateId, $filter) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh oh.. that adds so much "domain logic" to the controller.. Why did you decide to go for this approach instead of extending the filter and leaving implementation to the adapters?
The introduction of a With this pr introducing the The part where we use the So tltr. as we previously agreed on introducing the |
@@ -38,8 +38,6 @@ private function __construct( | |||
} | |||
|
|||
/** | |||
* If the value is NULL an unset-property instruction will be returned instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated and otherwise not changed file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know yeah that the comment is false was my fault and i fixed it ^^
@mhsdesign Thanks for the elaboration. I'm still a bit undecided to be honest, but I'll remove by -1 for now
Regarding the code duplication issue: We'll need this for the InMemory content graph anyway once it is to be fully implemented |
@@ -124,6 +124,11 @@ public function merge(self $other): self | |||
return self::fromArray($nodes); | |||
} | |||
|
|||
public function append(Node $node): self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With merge I would expect an instance of Nodes
. To add a single node to a set, "append" seems fine for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but it wouldn't be the first place we use a merge(Nodes::fromArray([$node]))
kind of construct ("upcast" single to collection). I just wanted to throw the question out there if we want to go down this route, because IMHO then we should add append (or similar) to other places probably?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places we named it more explicitly, like NodeTypeNames::withAdditionalNodeTypeName().
So we could call it withAppendedNode()
for example.
But IMO merge(Nodes::fromArray([$node]))
would be worse because it's
- harder to comprehend
- less explicit (with "append" it's clear that the new node is added to the end of the set)
- slower (OK, that is probably negligible)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw: I think prepend()
would make more sense in this example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, was mostly arguing for remembering to do it everywhere like this :) I am fine with having it, and yeah in htis case prepend
seems sensible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted as requested :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for re-opening, but when I suggested "Prepend" what I actually meant was withPrependedNode()
– but I'm not sure whether we use the with
er construct consistently everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh i see for collections the pattern as far as i have seen is to have merge
or a method union
and then i thought append
as well but i get your point.
@@ -12,7 +12,7 @@ | |||
|
|||
declare(strict_types=1); | |||
|
|||
namespace Neos\ContentRepository\Core\Projection\ContentGraph; | |||
namespace Neos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would almost argue the SearchTermMatcher doesn't belong in Projection/ContentGraph/Filters and that strengthens the argument the SearchTerm should be generic as well. Yes the SearchTermMatcher applies to contentgraph projection nodes, BUT I tihnk it's clear that everything else in filters is used in conjunction with a ContentGraph or Subgraph query (query in the loosest term not necessarily DB query), while the SearchTermMatcher applies to a set of nodes that have already been assembled. I think that is its own kind of operation.
@nezaniel and me went over this again and cleaned up the cosmetics. Regarding the odd search behaviour for non-string properties we agreed to keep it like the db implementation for now. And since there is no But are there any other suggestions for now? |
phpstan-baseline.neon
Outdated
- | ||
message: "#^Parameter \\#2 \\$searchTerm of static method Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentGraph\\\\Filter\\\\SearchTerm\\\\SearchTermMatcher\\:\\:matchesNode\\(\\) expects Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentGraph\\\\Filter\\\\SearchTerm\\\\SearchTerm, Neos\\\\ContentRepository\\\\Core\\\\Projection\\\\ContentGraph\\\\Filter\\\\SearchTerm\\\\SearchTerm\\|null given\\.$#" | ||
count: 1 | ||
path: Neos.Neos/Classes/Controller/Service/NodesController.php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o.O don't we hide a potential bug by skipping this warning?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the good qa :D Actually yes how did i miss that 🤯 :O
@@ -110,6 +114,11 @@ public function indexAction( | |||
string $contextNode = null, | |||
array|string $nodeIdentifiers = [] | |||
): void { | |||
$searchTerm = $searchTerm === '' ? null : SearchTerm::fulltext($searchTerm); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw: if you do use a different variable name, the error is detected by the IDE (or at least by the Php Inspections plugin):
It also suggests a follow-up change that makes sense:
) | ||
); | ||
if ( | ||
SearchTermMatcher::matchesNode($entryNode, $searchTerm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I read the code correctly, $searchTerm
can indeed be null
at this point leading to an exception..
Pushed an additional bugfix as discussed with @nezaniel: BUGFIX: Ignore empty search term in subgraph api when filtering previously using an |
Seems fine, I still think this should reside somewhere else but as it is internal I agree with could still move it, although this seems to be the kind of useful thing people will want to use and half of them will ignore the internal annotation then 😆 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed a temporary but sensible solution
If you search via the reference editor, the site node will never be found since we use
ContentSubgraphInterface::findDescendantNodes
from the starting point.We need a means to also check the entry point against the search term
$somehow
.This pr introduces an internal
SearchTermMatcher
similar to thePropertyValueCriteriaMatcher
to compare a nodes php-object properties against any given search term. Note that the behaviour seems currently a little weird but its modelled after our mariadb database implementation of the subgraph (see\Neos\ContentGraph\DoctrineDbalAdapter\NodeQueryBuilder::addSearchTermConstraints
).The intentional quirks might be adjusted and fixed altogether with the postgres implementation but since this is a purely internal api for now this is fine.
Further the
SearchTerm
behaviour was adjusted to imply no filtering when being empty""
.The new official behaviour is as follows:
Upgrade instructions
The
SearchTerm
was moved fromNeos\ContentRepository\Core\Projection\ContentGraph
intoNeos\ContentRepository\Core\Projection\ContentGraph\Filter\SearchTerm
Review instructions
See also our slack conversation: https://neos-project.slack.com/archives/C04PYL8H3/p1722437173713789
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions